<template>
    <div class="skuPics">
        <!-- 加个v-if解决刚刚开始数据还没拿到时的渲染警告报错 -->
        <img :src="imgBaseUrl+ pics[currentIndex].src"  class="showPic" v-if="pics">

        <ul class="imgList">
            <li v-for="item,index in pics" :key="index">
                <img :src="imgBaseUrl + item.src" 
                     :class="currentIndex==index?'active':''"
                     @mouseenter="picMousemove(index)" 
                >
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    props:['pics'],
    data() {
        return {
            coverImg:'',
            currentIndex: 0  //当前选中图片下标
        }
    },
    methods: {
        picMousemove(index){
            this.currentIndex = index
        }
    }
}
</script>

<style scoped lang="less">
    .skuPics{
        width: 450px;

        .showPic{
            width: 100%;
        }

        .imgList{
            margin-top: 20px;
            display: flex;
            justify-content: space-between;

            li{
                width: 100px;
                height: 100px;
                cursor: pointer;
                
                img{
                    width: 100%;
                    opacity: .4;
                }

            }

            .active{
                opacity: 1.0;
            }
        }
    }
</style>
